<?php

require_once('../../execute/auth.php');
//Start session
	@session_start();
	
	//Include database connection details
	require_once('inc/config.inc');
	
	
	
	//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}
	
	$news_title= $_POST['news_title'];
	$news_cat= $_POST['news_cat'];
	$user_id= $_POST['user_id'];
	$pub_date= $_POST['pub_date'];
	$news_body= $_POST['news_body'];
	
mysql_query ('SET NAMES utf8');
mysql_query('SET CHARACTER_SET utf8');
$insert=mysql_query("INSERT INTO news (title,content,news_cat,publisher_id,publish_date,news_stat) values('$news_title', '$news_body', '$news_cat', '$user_id', '$pub_date',1)")or die("Error: ".mysql_error());
//Status=0 means : initiated, 1 means: Approved by MoE, 2 means: Budged Allocated, 3 mean: Allotment Received, 4 means: Done
if($insert){
	?>
	<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-header">
	    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
	    <h3 id="myModalLabel">Thank you,</h3>
	  </div>
	  <div class="modal-body">
	    <p class="text-success lead">News has been Puplished Successfully!!!<?php echo "hello";?></p>
	  </div>
	  <div class="modal-footer">
	    <button class="btn btn-large btn-warning btn-block" data-dismiss="modal" aria-hidden="true">OK</button>
	    
	  </div>
	</div>
	
	<?php
	}
	else {
	?>
	<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-header">
	    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
	    <h3 id="myModalLabel">OOops!</h3>
	  </div>
	  <div class="modal-body">
	    <p class="text-error lead">Your News has not been Published Successfully!!</p>
	  </div>
	  <div class="modal-footer">
	    <button class="btn btn-large btn-danger btn-block" data-dismiss="modal" aria-hidden="true">Shut Up!</button>
	    
	  </div>
	</div>
	<?php
		
		}
		?>